package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.Dao.Impl.CompanyDaoImpl;
import com.ysd.Dao.Impl.NewsClassIficationDaoImpl;
import com.ysd.Dao.Impl.NewsDaoImpl;
import com.ysd.Dao.Impl.ProductDaoImpl;
import com.ysd.Dao.Impl.ProductSeriesDaoImpl;
import com.ysd.entity.Company;
import com.ysd.entity.News;
import com.ysd.entity.NewsClassiIfication;
import com.ysd.entity.Product;
import com.ysd.entity.ProductSeries;

public class ProductsServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//调用产品实现类的方法
				int psId = Integer.parseInt(request.getParameter("productSeriesId"));
				ProductDaoImpl pDao = new ProductDaoImpl();
				List<Product> p = pDao.getProductList(psId);//指定系列ID的产品数据
				request.setAttribute("p", p);//调用产品实现类
				ProductSeriesDaoImpl psDao = new ProductSeriesDaoImpl();
				List<ProductSeries> ps = psDao.getProductSeriesList();//获取产品系列
				request.setAttribute("ps", ps);//调用产品列表实现类
//				int pId = Integer.parseInt(request.getParameter("productId"));
//				ProductDaoImpl pDao2 = new ProductDaoImpl();
//				List<Product> cx = pDao2.getProductList1(pId);//指定id的产品详情
//				request.setAttribute("cx", cx);
				//调用产品列表实现类中的通过产品系列Id查询出指定id的数据
				int pssId = Integer.parseInt(request.getParameter("productSeriesId"));
				ProductSeriesDaoImpl pssDao = new ProductSeriesDaoImpl();
				ProductSeries pss = psDao.getProductSeriesList(pssId);//指定产品系列id的数据
				request.setAttribute("pss", pss);
				request.setAttribute("pssId", pssId);
		request.getRequestDispatcher("productlist.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
